// license-header java merge-point
/**
 * This is only generated once! It will never be overwritten.
 * You can (and have to!) safely modify it by hand.
 */
package fr.upstlse.glre.business.domain.depot;


/**
 * @see fr.upstlse.glre.business.domain.depot.Document
 */
public class DocumentDaoImpl
    extends fr.upstlse.glre.business.domain.depot.DocumentDaoBase
{
    /**
     * @see fr.upstlse.glre.business.domain.depot.DocumentDao#toDocumentVO(fr.upstlse.glre.business.domain.depot.Document, fr.upstlse.glre.business.vo.depot.DocumentVO)
     */
    public void toDocumentVO(
        fr.upstlse.glre.business.domain.depot.Document source,
        fr.upstlse.glre.business.vo.depot.DocumentVO target)
    {
        super.toDocumentVO(source, target);
        target.setLibelleVO(getLibelleDao().toLibelleVO(source.getLibelle()));
    }


    /**
     * @see fr.upstlse.glre.business.domain.depot.DocumentDao#toDocumentVO(fr.upstlse.glre.business.domain.depot.Document)
     */
    public fr.upstlse.glre.business.vo.depot.DocumentVO toDocumentVO(final fr.upstlse.glre.business.domain.depot.Document entity)
    {
        return super.toDocumentVO(entity);
    }


    /**
     * Retrieves the entity object that is associated with the specified value object
     * from the object store. If no such entity object exists in the object store,
     * a new, blank entity is created
     */
    private fr.upstlse.glre.business.domain.depot.Document loadDocumentFromDocumentVO(fr.upstlse.glre.business.vo.depot.DocumentVO documentVO)
    {
        fr.upstlse.glre.business.domain.depot.Document document = this.load(documentVO.getId());
        if (document == null)
        {
            document = fr.upstlse.glre.business.domain.depot.Document.Factory.newInstance();
        }
        return document;
    }

    
    /**
     * @see fr.upstlse.glre.business.domain.depot.DocumentDao#documentVOToEntity(fr.upstlse.glre.business.vo.depot.DocumentVO)
     */
    public fr.upstlse.glre.business.domain.depot.Document documentVOToEntity(fr.upstlse.glre.business.vo.depot.DocumentVO documentVO)
    {
        fr.upstlse.glre.business.domain.depot.Document entity = this.loadDocumentFromDocumentVO(documentVO);
        this.documentVOToEntity(documentVO, entity, true);
        return entity;
    }


    /**
     * @see fr.upstlse.glre.business.domain.depot.DocumentDao#documentVOToEntity(fr.upstlse.glre.business.vo.depot.DocumentVO, fr.upstlse.glre.business.domain.depot.Document)
     */
    public void documentVOToEntity(
        fr.upstlse.glre.business.vo.depot.DocumentVO source,
        fr.upstlse.glre.business.domain.depot.Document target,
        boolean copyIfNull)
    {
        super.documentVOToEntity(source, target, copyIfNull);
        if(copyIfNull || source.getLibelleVO() != null) {
        	target.setLibelle(getLibelleDao().libelleVOToEntity(source.getLibelleVO()));
        }
    }
}